﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.fminutes.vinciDll.analyze {
    import flash.events.*;
    import com.fminutes.vinciDll.*;
    import flash.utils.*;
    import flash.display.*;
    import flash.system.*;

    public class LibAnalyze extends AnalyzeBase {

        private var libList:Array;
        private var _appDomainList:Array;
        private var dataDic:Dictionary;
        private var funcDic:Dictionary;
        private var dllDic:Dictionary;
        private var _returnClassDic:Dictionary;

        public function LibAnalyze(){
            this.libList = [];
            this._appDomainList = [];
            this._returnClassDic = new Dictionary();
            super();
            this.dataDic = new Dictionary();
            this.funcDic = new Dictionary();
            this.dllDic = new Dictionary();
        }
        override public function analyze(_arg1:ByteArray, _arg2:DllFileObject, _arg3:Function):void{
            var _local4:Loader = new Loader();
            this.dataDic[_local4] = _arg1;
            this.funcDic[_local4] = _arg3;
            this.dllDic[_local4] = _arg2;
            _local4.loadBytes(_arg1);
            _local4.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onCompletefunc);
        }
        private function onCompletefunc(_arg1:Event):void{
            var _local2:Loader = _arg1.target.loader;
            _arg1.target.removeEventListener(Event.COMPLETE, this.onCompletefunc);
            this.dllDic[_local2].result = {
                data:this.dataDic[_local2],
                appDomain:_arg1.currentTarget.applicationDomain
            };
            this.dllDic[_local2].status = DllFileObject.LOADED;
            this.libList.push(this.dllDic[_local2]);
            this._appDomainList.push(this.dllDic[_local2].result.appDomain);
            var _local3 = this.funcDic;
            _local3[_local2]();
            delete this.dataDic[_local2];
            delete this.dllDic[_local2];
            delete this.funcDic[_local2];
            _local2 = null;
        }
        public function getByteArrayByName(_arg1:String):ByteArray{
            var _local3:DllFileObject;
            var _local2:int;
            while (_local2 < this.libList.length) {
                _local3 = (this.libList[_local2] as DllFileObject);
                if (_local3.name == _arg1){
                    return ((_local3.result["data"] as ByteArray));
                };
                _local2++;
            };
            return (null);
        }
        public function getDisplayObjectByName(_arg1:String):Object{
            var _local2:Class = this.getClassByName(_arg1);
            return ((_local2) ? new (_local2)() : null);
        }
        public function getClassByName(_arg1:String):Class{
            var _local2:Class;
            var _local4:ApplicationDomain;
            if (this._returnClassDic[_arg1]){
                return (this._returnClassDic[_arg1]);
            };
            var _local3:int;
            for each (_local4 in this._appDomainList) {
                if (_local4.hasDefinition(_arg1)){
                    _local2 = (_local4.getDefinition(_arg1) as Class);
                    this._returnClassDic[_arg1] = _local2;
                    break;
                };
            };
            return ((_local2) ? _local2 : null);
        }

    }
}//package com.fminutes.vinciDll.analyze 
